package com.views
{
	import mx.core.UIComponent;
	import flash.display.Sprite;
	import flash.geom.Point;

	/**
	 * Proxy Objekt für eine Aktivität
	 */
	public class ActivityProxy extends UIComponent implements IGraphElement, IGraphElementInfo
	{
		private var _width:int;
		private var _height:int;
		private var _background:Sprite;
		private var _position:Point;
		
		/**
		 * Konstruktor
		 * @param width
		 * @param height
		 * @return 
		 * 
		 */
		public function ActivityProxy(width:int, height:int)
		{
			_width = width;
			_height = height;
		}
		
		/**
		 * Hinzufügen der grundlegenden Elemente dieser Klasse.
		 * Wird genau einmal aufgerufen, dies findet während der
		 * Instanzierung statt.
		 */
		override protected function createChildren():void
		{
			super.createChildren();
			_background = drawRect(_width, _height);
			width = _background.getBounds(this).width;
			height = _background.getBounds(this).height;
			
			addChild(_background);
		}
		
		/**
		 * Zeichnen eines Rechtecks
		 * @param width
		 * @param height
		 * @return 
		 * 
		 */
		protected function drawRect(width:int, height:int):Sprite
		{
			var thickness:int = 2;
			var lineColor:uint = 0x0055FF;
			var selectedColor:uint = 0xCC0000;
			
			var sprite:Sprite = new Sprite();
			sprite.graphics.lineStyle(thickness, lineColor, 1);
			sprite.graphics.beginFill(0x0055FF, 0.5);
			var corner:int = height < width ? height / 4 : width / 4;
			sprite.graphics.drawRoundRect(0, 0, width, height, corner, corner);
			sprite.graphics.endFill();
			
			return sprite;
		}
		
		public function get background():Sprite
		{
			return _background;
		}
		public function get dataId():String
		{
			return "";
		}
		public function get selected():Boolean
		{
			return false;
		}
		public function set selected(value:Boolean):void
		{
			
		}
		public function set position(value:Point):void
		{
			_position = value;
		}
		public function get position():Point
		{
			return _position;
		}
		
	}
}